package dhee.wtqshopproject.utils;

import dhee.wtqshopproject.entity.User;

public class UserContext {
    private static final ThreadLocal<User> userHolder = new ThreadLocal<>();

    // 存储用户信息
    public static void setCurrentUser(User user) {
        userHolder.set(user);
    }

    // 获取用户信息
    public static User getCurrentUser() {
        return userHolder.get();
    }

    // 清除用户信息
    public static void remove() {
        userHolder.remove();
    }
}